<?php

// +------------------------------------------------
// | Name: 星空框架  系统菜单验证器
// +------------------------------------------------
// | Version: V5.0
// +------------------------------------------------
// | Author: xkyinzhe <zhonghuaxinxing@sina.cn>
// +------------------------------------------------
// | Time: 2021-04-19 13:35
// +------------------------------------------------
declare(strict_types=1);

namespace app\common\validate;

use think\Validate;

/**
 * @xk 系统菜单验证器
 */
class Menu extends Validate
{
    protected $rule = [
      'menu_id' => 'number|min:1',
      'menu_name' => 'require|min:2|max:100',
      'parent_id' => 'number|min:0', //不允许出现负数
      'menu_controller' => 'require',
      'order_id' => 'number|min:0',
      'status' => 'in:0,1',
    ];
    protected $message = [
      'menu_id.number' => '请选择需要操作的数据',
      'menu_name.require' => '请填写菜单名称',
      'parent_id.number' => '请选择所属上级菜单',
      'order_id.number' => '请按照规则填写排序ID',
      'menu_controller.require' => '请填写菜单方法控制器',
      'status' => '菜单状态不合法',
    ];
    protected $scene = [
      'create' => ['menu_name', 'parent_id', 'menu_controller', 'order_id', 'status'],
      'edit' => ['menu_id', 'menu_name', 'parent_id', 'menu_controller', 'order_id', 'status'],
      'name' => ['name'],
      'order_id' => ['order_id'],
      'status' => ['status'],
    ];
}
